import { http } from "@/http/request";

// 订单列表
export const getOrderList = (data: any) => {
	// return http.get(`/jinzhuangli-pm-service/as/order/list`, { data });
	return http.get(`/jinzhuangli-pm-service/as/order/list`, { data });
};

// 订单详情
export const getOrderDetail = (id: string) => {
	return http.get(`/jinzhuangli-pm-service/as/order/queryById?id=${id}`);
};

// 订单记录列表
export const getOrderRecordList = (id: string) => {
	return http.get(`/jinzhuangli-pm-service/as/order/record/list?asOrderId=${id}`);
};

// 到达现场
export const orderArrive = (id: string) => {
	return http.post(`/jinzhuangli-pm-service/as/order/arrive?asOrderId=${id}`);
};

interface CancelParams {
	asOrderId: string;
	cancelReasonItem: string;
	cancelReason: string;
	cancelReasonPic: string;
	visitAmount: string;
}
/**
 * 取消订单
 */
export const cancelOrder = (data: CancelParams) => {
	return http.post(`/jinzhuangli-pm-service/as/order/cancel`, data, {
		header: {
			"content-type": "application/x-www-form-urlencoded"
		}
	});
};

/**
 * 售后订单-更改预约时间
 */
export const updateOrderTime = (id: string, params: { serviceTime: string }) => {
	return http.post(`/jinzhuangli-pm-service/as/order/changeServiceTime?asOrderId=${id}&serviceTime=${params.serviceTime}`);
};

/**
 * 售后订单-完工
 */
export const updateOrderFinish = (data: { asOrderId: string; finishPic: string; finishRemark: string }) => {
	return http.post(`/jinzhuangli-pm-service/as/order/finish`, data, {
		header: {
			"content-type": "application/x-www-form-urlencoded"
		}
	});
};

/**
 * 编辑订单信息
 */
export const editOrderInfo = (data: any) => {
	return http.post(`/jinzhuangli-pm-service/as/order/pureEdit`, data);
};

interface SubmitRepairPlan {
	feeDetail: string;
	manpowerAmount: number;
	materialAmount: number;
	purchaseVoucherImg: string;
	asOrderId: string;
}
/**
 * 提交服务方案
 */
export const submitRepairPlan = (data: SubmitRepairPlan) => {
	return http.post(`/jinzhuangli-pm-service/as/order/submitScheme`, data);
};

/**
 * 获取服务列表
 */
export const getServiceList = (data: { pageNo: number; pageSize: number }) => {
	return http.get(`/jinzhuangli-pm-service/as/order/onSiteService/list`, { data });
};

/**
 * 材料商城 一级分类
 * @param {Object} params
 */
export function getShopCls(params: any) {
	return http.get(`/app/applet-product/jzMallProductClassification/one/list/sp`, {
		params
	});
}
/**
 * 材料商城 查询下级分类
 * @param {String} id
 */
export function getNextShopCls(id: string) {
	return http.get(`/app/applet-product/jzMallProductClassification/next/${id}`);
}
/**
 * 材料商城 查询分类的品牌
 * @param {String} id 分类id
 * @param {String} lv 品牌档次
 */
export function getShopClsBrandV(id: string, lv: string = "") {
	return http.get(`/app/setting/brand/list?salesClassificationId=${id}&brandLevel=${lv}`);
}
/**
 * 材料商城 查询分类的品牌
 * @param {String} id 分类id
 */
export function getShopClsBrand(id: string) {
	return http.get(`/app/setting/brand/list/classification/${id}`);
}
/**
 * 材料商城 查询分类的品牌
 * @param {String} classificationId 分类id
 * @param {String} brandId 品牌
 * @param {String} costPrice 显示成本价
 * @param {String} keyword 搜索关键字
 * @param {String} pageNo 分页
 *
 */
export function getShopList(params: any) {
	return http.get(`/app/product/base/list/all`, {
		params
	});
}

/**
 * 材料商城 查询分类的品牌
 * @param {String} classificationId 分类id
 * @param {String} deleteStatus 是否删除
 * @param {String} verifyStatus //	审核状态 0->未审核；1->审核通过；2->审核不通过
 * @param {String} publishStatus 上架状态
 * @param {String} keyword 搜索关键字
 * @param {String} pageNo 分页
 *
 */
export function getShopListV(params: { classificationId: string; deleteStatus: string; verifyStatus: string; publishStatus: string; keyword: string; pageNo: string | number }) {
	return http.get(`/app/product/spu/list`, {
		params
	});
}

/**
 * 营销商品分类tree
 * @param {Object} params
 */
export function getSpuClassify(params: any) {
	return http.get(`/app/product/spu/tree`, {
		params
	});
}

/**
 *
 * @param {asOrderId:string;payVoucherCheckStatus:0|1|2;payVoucherCheckRemark:string} params '支付凭据检查状态 0:待检查 1:通过 2:未通过',
 * @return
 */
export function checkPayVoucher(params: { asOrderId: string; payVoucherCheckStatus: 0 | 1 | 2; payVoucherCheckRemark: string }) {
	return http.post(`/jinzhuangli-pm-service/as/order/checkPayVoucher`, params, {
		header: {
			"content-type": "application/x-www-form-urlencoded"
		}
	});
}

/**
 * 查询商品信息
 * @param {String} id
 */
export function getShopDetail(id: string) {
	return http.get(`/app/product/spu/info/${id}`);
}
